#include <iostream>
#include <stdio.h>

class Base
{
	public:
		void function_1()
		{
			printf("function_1...\n");
		}

		virtual void function_2()
		{
			printf("function_2...\n");
		}
};

int main(int argc, char ** argv)
{
	Base base;

	printf("size %d\n", sizeof(class Base));	// 4, 没有virtual, 为 1

	base.function_1();
	base.function_2();
}

#if 0

对象调用时，虚与普通函数没有区别。

int main(int argc, char ** argv)
{
 8048640:	55                   	push   %ebp
 8048641:	89 e5                	mov    %esp,%ebp
 8048643:	83 e4 f0             	and    $0xfffffff0,%esp
 8048646:	83 ec 20             	sub    $0x20,%esp
	Base base;
 8048649:	8d 44 24 1c          	lea    0x1c(%esp),%eax
 804864d:	89 04 24             	mov    %eax,(%esp)
 8048650:	e8 a3 00 00 00       	call   80486f8 <_ZN4BaseC1Ev>

	base.function_1();
 8048655:	8d 44 24 1c          	lea    0x1c(%esp),%eax		# this 指针，此乃函数放类或结构体里面和外面唯一的区别。放里面有多传this指针。
 8048659:	89 04 24             	mov    %eax,(%esp)
 804865c:	e8 6f 00 00 00       	call   80486d0 <_ZN4Base10function_1Ev>		# E8 call 是直接调用
	base.function_2();
 8048661:	8d 44 24 1c          	lea    0x1c(%esp),%eax
 8048665:	89 04 24             	mov    %eax,(%esp)
 8048668:	e8 77 00 00 00       	call   80486e4 <_ZN4Base10function_2Ev>		# E8 call 是直接调用
}
 804866d:	b8 00 00 00 00       	mov    $0x0,%eax
 8048672:	c9                   	leave  
 8048673:	c3                   	ret 


#endif
